/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header$
 * $Id$
 * $Author$
 * $Date$
 * $Revision$
 */
package com.elancom.framework.test.testng;

import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.ITable;

/**
 * @author elancom
 * @date 2012-7-19
 */
public class TableRow {
	private ITable table;
	private int rowIndex;

	/**
	 * @param table
	 * @param rowIndexs
	 */
	public TableRow(ITable table, int rowIndex) {
		super();
		this.table = table;
		this.rowIndex = rowIndex;
	}

	/**
	 * @param row
	 * @return
	 * @throws DataSetException
	 * @see org.dbunit.dataset.ITable#getValue(int, java.lang.String)
	 */
	public <T> T getValue(String column) throws DataSetException {
		return getValue(rowIndex, column);
	}

	public String getString(String column) throws DataSetException {
		return getValue(rowIndex, column);
	}

	public Integer getInt(String column) throws DataSetException {
		String str = getValue(rowIndex, column);
		return Integer.valueOf(str);
	}

	/**
	 * @param row
	 * @param column
	 * @return
	 * @throws DataSetException
	 * @see org.dbunit.dataset.ITable#getValue(int, java.lang.String)
	 */
	@SuppressWarnings("unchecked")
	public <T> T getValue(int rowIndex, String column) throws DataSetException {
		return (T) table.getValue(rowIndex, column);
	}

	/**
	 * @return the table
	 */
	public ITable getTable() {
		return table;
	}

	/**
	 * @param table
	 *            the table to set
	 */
	public void setTable(ITable table) {
		this.table = table;
	}

	/**
	 * @return the rowIndex
	 */
	public int getRowIndex() {
		return rowIndex;
	}

	/**
	 * @param rowIndex
	 *            the rowIndex to set
	 */
	public void setRowIndex(int rowIndex) {
		this.rowIndex = rowIndex;
	}

}
